<div class="tools" ng-if="!pagedata.isprint">
	<div class="btn btn-success block btn-submit" style="border-radius:1rem" onclick="printTable('dataTable')">打印本页</div>
</div>
<style>
	.title{
        text-align: center;
        font-size: 20px;
    }
    .dataTable{
       position:relative; width: 100%;height: auto;padding:0 10px;
    }
</style>
<div class="dataTable"  id="dataTable" style="margin-top:0">
<style>
    .title{
        text-align: center;
         font-size: 20px;font-weight: 600;margin: 20px 0;
    }
    .topbox{
        display: flex;align-items: center;
    }
    .topbox .left{flex: 1}
    .topbox .right{flex: 1}
    td{
        height: 22px;line-height: 22px;padding:3px;font-size: 12px; !important;
    }
    .box-table{
        border-collapse:collapse;border:none;
    }
    .box-table td{
        box-sizing: border-box;
        height: 22px;
        line-height: 22px;
    }
    .top-table td{
        text-align: left!important;
    }
</style>
    <table border="0" class="top-table" cellpadding="15" cellspacing="1" style="width: 100%;padding:15px 0">
      <thead>
        <tr>
            <td  colspan="2" class="th-in title" style="text-align: center!important;padding:15px">
               {{pagedata.basic.toptitle || '发货单'}}
            </td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td align="left">
              客户名称 : {{pagedata.item.name}}
            </td>
            <td align="left">
                下单时间 : {{check_show_lang(pagedata.item.createtime)}}
            </td>
        </tr>
        <tr>
            <td align="left">
                订单编号 : {{pagedata.item.ordersn}}
            </td>
            <td align="left">
                支付方式 : {{check_show_lang(pagedata.item.paytype)}}
            </td>
        </tr>
        <tr>
            <td align="left">
                联系人 : {{pagedata.item.name}}
            </td>
            <td align="left">
                联系电话 : {{pagedata.item.mobile}}
            </td>
        </tr>
        <tr>
            <td colspan="1.7" >
               客户地址 : {{check_show_lang(pagedata.item.address)}}
            </td>
            <td colspan="1.5" >
                配送方式 :  {{pagedata.item.sendtypetitle}}
				<span ng-if="pagedata.self && pagedata.self.number" class="text-default">
                       (取货号:<span class="red">{{pagedata.self.number}}</span>)
                 </span>
            </td>
        </tr>
        </tbody>
    </table>
    <table class="box-table" border="1" cellpadding="15" cellspacing="0" style="width: 100%;font-size: 15px;margin-top:5px">
        <tr >
            <td  style="text-align:center" >商品编号</td>
            <td  style="text-align:center" >供货商</td>
            <td  style="text-align:center">商品名称</td>
            <td  style="text-align:center">规格</td>
            <td  style="text-align:center">单位</td>
            <td style="text-align:center">单价</td>
            <td style="text-align:center">数量</td>
            <td style="text-align:center">应收</td>
            <!--<td style="text-align:center;width: 14%; padding: 4px 10px;font-size: 14px;">备注</td>-->
        </tr>
        <tr ng-repeat="g in pagedata.item.goods">
            <td style="text-align:center" >{{g.goodsid}}</td>
            <td style="text-align:center" >{{g.merchtitle}}</td>
            <td  style="text-align:center" >{{g.title}}</td>
            <td style="width: 10%; padding: 4px 10px;font-size: 12px;">{{g.selespename || '无'}}</td>
            <!--<td  style="text-align:center" >{{g.subtitle}}</td>-->
            <!--<td  style="text-align:center" >{{g.subtitle}}</td>-->
            
            <td style="text-align:center">{{g.unit||'件'}}</td>
            <td  style="text-align:center" >{{g.price}}</td>
            <td  style="text-align:center">{{g.total}}</td>
            <td style="text-align:center" >{{check_show_lang('￥_$')}}{{price(g.total * g.price)}}</td>
            <!--<td style="width: 14%; padding: 4px 10px;font-size: 14px;"></td>-->
        </tr>
        <tr >
            <td>合计</td>
            <td colspan="7" style="text-align:left">
                <span style="margin-right:10px" > <span class="price-inner">{{check_show_lang('商品小计_Subtotal')}}：</span><span style="font-weight: bold">{{check_show_lang('￥_$')}}{{pagedata.item.goodsprice}}</span></span> 
				<span><span class="price-inner">{{check_show_lang('运费_Dispatch price')}}：</span>{{check_show_lang('￥_$')}}{{pagedata.item.dispatchprice}}</span>
                <span style="margin-right:10px" ng-if="!pagedata.item.ispackage && pagedata.item.taskdiscountprice>0"><span class="price-inner">任务活动优惠：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.taskdiscountprice}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.lotterydiscountprice>0"><span class="price-inner">游戏活动优惠：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.lotterydiscountprice}}</span></span>
 
                <span  style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.level_de_price>0"><span class="price-inner">会员折扣：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.level_de_price}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.delcredit1>0"><span class="price-inner">积分抵扣：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.delcredit1}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.deductcredit>0"><span class="price-inner">余额抵扣：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.deductcredit}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.enough_de_price>0"><span class="price-inner">满额立减：</span><span class="text-danger" style="font-weight: bold">-{{check_show_lang('￥_$')}}{{pagedata.item.enough_de_price}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.merchdeductenough>0"><span class="price-inner">商户满额立减：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.merchdeductenough}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.coupon_de_price>0"><span class="price-inner">优惠券优惠：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.coupon_de_price}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.luck_de_price>0"><span class="price-inner">运势优惠：</span><span class="text-danger">-￥{{pagedata.item.luck_de_price}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.isdiscountprice>0"><span class="price-inner">促销优惠：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.isdiscountprice}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.buyagainprice>0"><span class="price-inner">重复购买优惠：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.buyagainprice}}</span></span>
 
                <span style="margin-right:10px"  ng-if="!pagedata.item.ispackage && pagedata.item.seckilldiscountprice>0"><span class="price-inner">秒杀优惠：</span><span class="text-danger">-{{check_show_lang('￥_$')}}{{pagedata.item.seckilldiscountprice}}</span></span>
 
                <span style="margin-right:10px"  ng-if="pagedata.item.changeprice!=0">
                    <span class="price-inner">卖家改价：</span>
                    <span ng-class="{'green':pagedata.item.changeprice>0}">{{pagedata.item.changeprice>0?'+':'-'}}{{check_show_lang('￥_$')}}{{price(pagedata.item.changeprice)}}</span>
                </span>
 
                <span style="margin-right:10px"  ng-if="pagedata.item.changedispatchprice!=0">
                    <span class="price-inner">卖家改运费：</span>
                    <span ng-class="{'green':pagedata.item.changedispatchprice>0}" >{{pagedata.item.changedispatchprice>0?'+':'-'}}{{check_show_lang('￥_$')}}{{price(pagedata.item.changedispatchprice)}}</span>
                </span>
 
                <span style="margin-right:10px"  ng-if="pagedata.item.addprice!='0.00'">
                    <span class="price-inner">多退少补：</span>
                    <span style="font-size: 14px;font-weight: bold;color: #e4393c">￥{{pagedata.item.addprice || '0.00'}}</span>
                </span>
 
                <span style="margin-right:10px" ><span class="price-inner">{{check_show_lang('实付款_Real pay')}}：</span><span style="font-size: 14px;font-weight: bold">{{check_show_lang('￥_$')}}{{pagedata.item.price}}</span></span>
            </td>
        </tr>
       <tr>
            <td colspan="8" style="text-align:left;height:80px;padding-left:15px;">备注：{{check_show_lang(pagedata.item.remark)}}</td>
        </tr>
        <!--{{check_show_lang(pagedata.item.remark)}}-->
    </table>
	<div style="color:#999;padding:15px;font-size: 13px;">
		打印时间：{{pagedata.datime}}
	</div>
	<div style="position:absolute;bottom:20px;right:60px">
		<img ng-if="pagedata.basic.code" style="height:100px;width:100px;opacity:0.5;" ng-src="{{tomedia(pagedata.basic.code)}}"/>
	</div>
</div>
<script>
//打印表格
var idTmr;
window.addEventListener('afterprint', function() {  
    console.log('Printing completed or canceled...');  
    scope.pagedata.isprint=false
	scope.$evalAsync();
});  
function getExplorer() {
        var explorer = window.navigator.userAgent;
        //ie
        if(explorer.indexOf("MSIE") >= 0) {
            return 'ie';
        }
        //firefox
        else if(explorer.indexOf("Firefox") >= 0) {
            return 'Firefox';
        }
        //Chrome
        else if(explorer.indexOf("Chrome") >= 0) {
            return 'Chrome';
        }
        //Opera
        else if(explorer.indexOf("Opera") >= 0) {
            return 'Opera';
        }
        //Safari
        else if(explorer.indexOf("Safari") >= 0) {
            return 'Safari';
        }
}
//打印表格
function printTable(tableid){
    scope.pagedata.isprint=true
	scope.$evalAsync();
	setTimeout(function () {
		window.print();
	},200);
}
function method5(tableid) {
        if(getExplorer() == 'ie') {
            var curTbl = document.getElementById(tableid);
            var oXL = new ActiveXObject("Excel.Application");
            var oWB = oXL.Workbooks.Add();
            var xlsheet = oWB.Worksheets(1);
            var sel = document.body.createTextRange();
            sel.moveToElementText(curTbl);
            sel.select();
            sel.execCommand("Copy");
            xlsheet.Paste();
            oXL.Visible = true;
            try {
                var fname = oXL.Application.GetSaveAsFilename("Excel.xls",
                    "Excel Spreadsheets (*.xls), *.xls");
            } catch(e) {
                print("Nested catch caught " + e);
            } finally {
                oWB.SaveAs(fname);
                oWB.Close(savechanges = false);
                oXL.Quit();
                oXL = null;
                idTmr = window.setInterval("Cleanup();", 1);
            }
        } else {
            tableToExcel(tableid)
        }
    }
    function Cleanup() {
        window.clearInterval(idTmr);
        CollectGarbage();
    }
    var tableToExcel = (function() {
        var uri = 'data:application/vnd.ms-excel;base64,',
            template = '<html><head><meta charset="UTF-8"></head><body><table  border="1">{table}</table></body></html>',
            base64 = function(
                s) {
                return window.btoa(unescape(encodeURIComponent(s)))
            },
            format = function(s, c) {
                return s.replace(/{(\w+)}/g, function(m, p) {
                    return c[p];
                })
            }
        return function(table, name) {
            if(!table.nodeType)
                table = document.getElementById(table)
            var ctx = {
                worksheet: name || 'Worksheet',
                table: table.innerHTML
            }
            window.location.href = uri + base64(format(template, ctx))
        }
    })()
</script>